<template>
  <a-drawer v-model:visible="visible" title="航空机票订单详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="订单ID">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="订单编号">{{ dataDetail?.orderNumber }}</a-descriptions-item>
      <a-descriptions-item label="乘客姓名">{{ dataDetail?.passengerName }}</a-descriptions-item>
      <a-descriptions-item label="航班号">{{ dataDetail?.flightNumber }}</a-descriptions-item>
      <a-descriptions-item label="出发城市">{{ dataDetail?.departureCity }}</a-descriptions-item>
      <a-descriptions-item label="到达城市">{{ dataDetail?.arrivalCity }}</a-descriptions-item>
      <a-descriptions-item label="出发时间">{{ dataDetail?.departureTime }}</a-descriptions-item>
      <a-descriptions-item label="到达时间">{{ dataDetail?.arrivalTime }}</a-descriptions-item>
      <a-descriptions-item label="票价">{{ dataDetail?.ticketPrice }}</a-descriptions-item>
      <a-descriptions-item label="订单状态">{{ dataDetail?.orderStatus }}</a-descriptions-item>
      <a-descriptions-item label="订单创建时间">{{ dataDetail?.createdAt }}</a-descriptions-item>
      <a-descriptions-item label="订单更新时间">{{ dataDetail?.updatedAt }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
import { type TicketOrdersDetailResp, getTicketOrders as getDetail } from '@/apis/test/ticketOrders'

const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<TicketOrdersDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
